<template>
  <div class="art-container">
    <div class="article-detail">
      <div class="article-title">
        <div class="setleft">
          <div>
            {{ articleInfo.title }}
            <span class="goback" @click="goBack">返回</span>
          </div>
          <div class="time">
            <i class="iconfont icon-shizhong4"></i>
            {{ articleInfo.createdate | formatTime }}
          </div>
        </div>
      </div>
      <div class="content">
        <div class="ovflh" v-html="articleInfo.content"></div>
      </div>
    </div>
  </div>
</template>

<script>
import userUtils from '@/utils/userUtil'
import api from '@/config/api'
import { sendPost } from '@/utils/http'
export default {
  data () {
    return {
      articleInfo: {}, // 文章详情
    }
  },
  created () {
    console.log(this.$route.query.id);
    this.getInformation(this.$route.query.id)

    window.scrollTo({
      left: 0,
      top: 0,
      behavior: 'smooth'
    })

  },
  methods: {
    getInformation (id) {
      sendPost(api.getInformation, { id: id }).then(res => {
        console.log(res);
        this.articleInfo = res.data
      })
    },
    goBack () {
      this.$router.go(-1)
    }
  },
}
</script>

<style lang="less" scoped>
.art-container {
  width: 50rem;
  margin: auto;
}
.article-detail {
  width: 46.625rem;
  .article-title {
    font-size: 2.125rem;
    margin-top: 3.125rem;
    height: 6.875rem;
    border-bottom: 0.0625rem solid #ededed;
    color: #333;
    display: flex;
    justify-content: space-between;
    position: relative;
    .goback {
      position: absolute;
      right: 0;
      bottom: 0;
      font-size: 1.125rem;
      width: 6.25rem;
      height: 2.1875rem;
      line-height: 2.1875rem;
      background: #fffafa;
      border: 0.0625rem solid #ff5e4e;
      border-radius: 0.1875rem;
      text-align: center;
      color: #fff;
      background-color: #ff5e4e;
      margin: auto;
      margin-right: 0;
      cursor: pointer;
    }
  }
  .time {
    font-size: 1rem;
    color: #999;
    margin-top: 0.625rem;
  }
  .content {
    padding-top: 3.125rem;
    color: #333333;
    line-height: 2rem;
    font-size: 1rem;
    margin-bottom: 4.0625rem;
  }
  .article-img {
    width: 23rem;
    height: 30.25rem;
    margin: auto;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
